<?php
/**
 * @file WCParserBehaviorVAR.php
 * @author Alejandro Dario Simi
 * @date $Date: 2012-12-28 01:08:14 +0000 (Fri, 28 Dec 2012) $
 *
 * $Id: WCParserBehaviorVAR.php 47 2012-12-28 01:08:14Z daemonraco@gmail.com $
 * $URL: http://wcomix.googlecode.com/svn/tags/wcomix-1.0-BETA1/includes/parser/WCParserBehaviorVAR.php $
 */

require_once dirname(__FILE__)."/WCParserBehavior.php";

$WCParserBehaviorMatrix["VAR"]	= "WCParserBehaviorVAR";

class WCParserBehaviorVAR extends WCParserBehavior {
	public function check() {
		if($this->_node) {
			if(count($this->_node->children()) > 1) {
				$this->_errorMsg = "node has more than one children";
				$this->_ok = false;
			} else {
				$this->_ok = true;
				$this->_errorMsg = "Ok";
			}
		} else {
			$this->_errorMsg = "VAR node is not set";
			$this->_ok = false;
		}

		return $this->isOk();
	}
	public function get() {
		if($this->isOk()) {
			$parser = $this->_node->parser();
			$children = $this->_node->children();
			$variable = $children[0];
			return $parser->$variable;
		} else {
			return false;
		}
	}
}

?>